<template>
  <div class="p-2">
    <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
      <div class="search" v-show="showSearch">
        <el-form :model="queryParams" ref="queryFormRef" :inline="true" label-width="68px" class="search-form">
          <el-form-item label="编号" prop="shiftName">
            <el-input placeholder="请输入名称" v-model="queryParams.spotNumber" clearable style="width: 240px" />
          </el-form-item>
          <el-form-item label="名称" prop="shiftName">
            <el-input placeholder="请输入名称" v-model="queryParams.spotName" clearable style="width: 240px" />
          </el-form-item>

          <el-form-item label="点状态" prop="spotStatus">
            <el-select v-model="queryParams.spotStatus" placeholder="请选择" clearable>
              <el-option v-for="dict in spotstatusarr" :key="dict.id" :label="dict.label" :value="dict.id" />
            </el-select>
          </el-form-item>
          <el-form-item label="巡检路线" prop="studentStatus">
            <el-select v-model="queryParams.routeName" placeholder="请选择路线" clearable>
              <el-option v-for="dict in routeOptions" :key="dict.routeId" :label="dict.routeName" :value="dict.routeId" />
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
            <el-button icon="Refresh" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-form>
      </div>
    </transition>

    <el-card shadow="never">
      <template #header>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['attendance:shift:add']">新增</el-button>
          </el-col>
          <!-- <el-col :span="1.5">
            <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['attendance:shift:edit']"
              >修改</el-button
            >
          </el-col>
          <el-col :span="1.5">
            <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['attendance:shift:remove']"
              >删除</el-button
            >
          </el-col> -->
          <el-col :span="1.5">
            <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['attendance:shift:remove']"
              >删除</el-button
            >
          </el-col>
          <el-col :span="1.5">
            <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['attendance:shift:export']">导出</el-button>
          </el-col>
          <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
        </el-row>
      </template>

      <el-table
        height="calc(100vh - 360px)"
        v-loading="loading"
        :data="portsSettingList"
        @selection-change="handleSelectionChange"
        :row-key="(row) => row.spotId"
      >
        <el-table-column type="selection" :reserve-selection="true" width="55" />
        <el-table-column label="编号" align="center" prop="spotNumber" />
        <el-table-column label="点名称" align="center" prop="spotName" />
        <el-table-column label="点状态" align="center" prop="spotStatus" >
          <template #default="scope">
            <div v-if="scope.row.spotStatus=='0'">
              正常
            </div>
            <div v-if="scope.row.spotStatus=='1'">
              异常
            </div>
            <div v-if="scope.row.spotStatus=='2'">
              处理中
            </div>
            <div></div>
          </template>
        </el-table-column>
        <el-table-column label="拍照数量" align="center" prop="pictureNum" />
        <el-table-column label="巡检路线" align="center" prop="routeName" />
        <el-table-column label="检查项目" align="center" prop="inspectItems" />
        <el-table-column label="分类目录" align="center" prop="catalogueId" />
        <el-table-column label="最后修改人" align="center" prop="updateByName" />
        <el-table-column label="最后修改时间" align="center" prop="updateTime" />
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template #default="scope">
            <el-tooltip content="修改" placement="top">
              <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"></el-button>
            </el-tooltip>
            <el-tooltip content="删除" placement="top">
              <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"></el-button>
            </el-tooltip>
          </template>
        </el-table-column>
      </el-table>
      <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
    </el-card>
    <!-- 新增或修改巡检点弹窗 -->
    <el-dialog :title="dialog.title" v-model="dialog.visible" width="900px" append-to-body>
      <el-row>
        <el-col :span="form.spotId && typeof form.spotId !== undefined  ? 16: 24">
          <el-form ref="studentRecognitionRecordFormRef" :model="form" :rules="rules" label-position="right" label-width="120px">
            <el-form-item label="点编号" prop="spotNumber">
              <el-input v-model="form.spotNumber" type="number" placeholder="请输入点编号" />
            </el-form-item>
            <el-form-item label="点名称" prop="spotName">
              <el-input v-model="form.spotName" placeholder="请输入点名称" />
            </el-form-item>
            <el-form-item label="地址" prop="spotAddress">
              <el-input type="textarea" v-model="form.spotAddress" placeholder="请输入地址" />
            </el-form-item>
            <el-form-item label="状态" prop="enableStatus">
              <el-select v-model="form.enableStatus" placeholder="状态">
                <el-option v-for="dict in onoffArr" :key="dict.id" :label="dict.label" :value="dict.id"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="所属分类目录" prop="catalogueId">
              <el-select v-model="form.catalogueId" placeholder="请选择">
                <el-option v-for="item in groupOptions" :key="item.catalogueId" :label="item.catalogueName" :value="item.catalogueId"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="巡检路线" prop="routeIds">
              <el-select v-model="form.routeIds" placeholder="请选择" multiple>
                <el-option v-for="item in routeOptions" :key="item.routeId" :label="item.routeName" :value="item.routeId"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="当前点状态" prop="spotStatus">
              <el-select v-model="form.spotStatus" placeholder="请选择级别">
                <el-option v-for="dict in spotstatusarr" :key="dict.id" :label="dict.label" :value="dict.id"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="任务状态" prop="taskStatus">
              <el-select v-model="form.taskStatus" placeholder="请选择">
                <el-option v-for="dict in taskstatusarr" :key="dict.id" :label="dict.label" :value="dict.id"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="扫一扫照片" prop="pictureStatus">
              <el-select v-model="form.pictureStatus" placeholder="请选择">
                <el-option v-for="dict in photosave" :key="dict.id" :label="dict.label" :value="dict.id"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="最少拍照" prop="pictureLess">
              <el-input-number v-model="form.pictureLess" :min="0" label="描述文字"></el-input-number>
            </el-form-item>
            <el-form-item label="最多拍照" prop="pictureMany">
              <el-input-number v-model="form.pictureMany" :min="0" label="描述文字"></el-input-number>
            </el-form-item>
            <el-form-item label="巡检说明" prop="inspectExplain">
              <el-input type="textarea" v-model="form.inspectExplain" placeholder="请输入说明" />
            </el-form-item>
            <el-form-item label="检查项目" prop="items">
              <el-button type="primary" :icon="Plus" size="small" @click="onClickAdd">添加</el-button>
              <el-button type="danger" :icon="Delete" size="small" @click="onClickDelete" :disabled="selectData.length === 0">删除</el-button>
              <div class="row-grid attrs-table">
                <div class="row-grid-header">
                  <div class="row-grid-tr">
                    <div class="row-grid-td serial">序号</div>
                    <div class="row-grid-td name1">
                      <el-checkbox style="margin-left: 10px;" v-model="checkAll" @change="onChangeCheckBoxAll"></el-checkbox>
                    </div>
                    <div class="row-grid-td namemax row-grid-center">检查项目名称</div>
                    <div class="row-grid-td name1">抽奖概率（%）</div>
                    <div class="row-grid-td name1">类型</div>
                    <div class="row-grid-td name1">必填</div>
                    <div class="row-grid-td name1">得分</div>
                  </div>
                </div>
                <draggable
                  class="row-grid--draggable"
                  v-model="selectData"
                  chosenClass="row-grid-tr--chosen"
                  ghostClass="row-grid-tr--ghost"
                  dragClass="row-grid-tr--drag"
                  :forceFallback="true"
                  :item-key="(item: any) => item.routeId"
                  handle=".serial"
                  @start="true"
                  @end="draggerEnd"
                >
                  <template #item="{ element, index }">
                    <div class="row-grid-tr">
                      <div class="row-grid-td serial">
                        <el-icon>
                          <Sort />
                        </el-icon>
                        {{ index + 1 }}
                      </div>
                      <div class="row-grid-td name1">
                        <el-checkbox v-model="element.checked"></el-checkbox>
                      </div>
                      <div class="row-grid-td namemax">
                        {{element.itemsName}}
                      </div>
                      <div class="row-grid-td name1">
                        <el-input-number
                          size="small"
                          :controls="false"
                          :precision="0"
                          :max="100"
                          :min="0"
                          style="width: 50px;"
                          v-model="element.chance"
                          type="number"
                        ></el-input-number>
                      </div>
                      <div class="row-grid-td name1">
                        {{typeArr[element.itemsType]}}
                      </div>
                      <div class="row-grid-td name1">
                        {{element.isRequired === '0' ? '否' : '是'}}
                      </div>
                      <div class="row-grid-td name1">
                        {{element.isScore === '0' ? '否' : '是'}}
                      </div>
                    </div>
                  </template>
                </draggable>
              </div>
            </el-form-item>
          </el-form>
        </el-col>
        <el-col v-if="(form.spotId && typeof form.spotId !== undefined && form.qrCode)" :span="8" style="padding: 0px 20px;">
          <el-collapse v-model="activeNames">
            <el-collapse-item name="1">
              <template #title> <div style="text-align: center;width: 100%;font-weight:bold;">巡检码</div> </template>
              <div style="text-align: center;">
                <img :src="'data:image/png;base64,' + form.qrCode" :size="200" />
                <div style="font-size: 12px;">{{ (form.spotName ? form.spotName : '') + (form.spotAddress ?  form.spotAddress : '')}}</div>
                <div>
                  <!-- 打印 -->
                  <el-button @click="onClickPrint" type="primary" size="small"
                    >打印<el-icon><Printer /></el-icon
                  ></el-button>
                  <el-button @click="onClickDowload" type="primary" size="small"
                    >另存<el-icon><Download /></el-icon
                  ></el-button>
                </div>
              </div>
            </el-collapse-item>
          </el-collapse>
        </el-col>
      </el-row>
      <template #footer>
        <div class="dialog-footer">
          <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>
    <addCheck :visible="addCheckVisiable" @closeDialog="closeAddCheckDialog" @getSelectData="getSelectData" />
  </div>
</template>

<script setup name="portsSetting" lang="ts">
import { inspectionPointsForm, inspectionPointsQuery } from '@/api/inspection/spot/types'
import {  inspectspotlist, searchinspectItemsCatalogue } from '@/api/inspection';
import { ApiGetInspectionRouteList } from '@/api/inspection/inspectionroute';
import { ApiCreateInspectionSpot, ApiGetInspectionSpotDetail, ApiUpdateInspectionSpot, ApiDeleteInspectionSpot } from '@/api/inspection/spot';
import { Delete, Plus } from '@element-plus/icons-vue';
import addCheck from './childrens/addCheck.vue';
import draggable from 'vuedraggable';
import printJS from 'print-js';

const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const {  student_school_status } = toRefs<any>(
  proxy?.useDict('school_grade_level', 'device_type', 'student_sex', 'student_school_status')
);

const portsSettingList = ref<inspectionPointsForm[]>([]);
const buttonLoading = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref<any>([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const groupOptions = ref<any[]>([]);
const addCheckVisiable = ref(false);
const selectData: any = ref([]);
const checkAll = ref(false);
const routeOptions = ref<any[]>([]);
//启用状态
const activeNames = ref<string[]>(['1']);
const onoffArr = ref<any[]>([
  {
    id: '1',
    label: '正常启用'
  },
  {
    id: '2',
    label: '暂停使用'
  }
]);

const typeArr = [
   '选择项',
   '数字项',
   '文本项',
   '拍照项',
]

//点状态
const spotstatusarr = ref<any[]>([
  {
    id: '0',
    label: '正常'
  },
  {
    id: '1',
    label: '异常'
  },
  {
    id: '2',
    label: '处理中'
  }
]);
//任务状态
const taskstatusarr = ref<any[]>([
  {
    id: '1',
    label: '无'
  },
  {
    id: '2',
    label: '正在处理'
  },
  {
    id: '3',
    label: '已经完成'
  },
  {
    id: '4',
    label: '已经取消'
  },
  {
    id: '5',
    label: '超时任务'
  }
]);
//照片保存
const photosave = ref<any[]>([
  {
    id: '1',
    label: '保存'
  },
  {
    id: '2',
    label: '不保存'
  }
]);
const queryFormRef = ref<ElFormInstance>();
const studentRecognitionRecordFormRef = ref<ElFormInstance>();

const dialog = reactive<DialogOption>({
  visible: false,
  title: ''
});

const initFormData: inspectionPointsForm = {
  spotNumber: '',
  spotName: undefined,
  spotAddress: undefined,
  enableStatus: undefined,
  catalogueId: undefined,
  routeIds: [],
  spotStatus: '1',
  taskStatus: undefined,
  pictureStatus: undefined,
  pictureLess: 0,
  pictureMany: 0,
  items: []
};
const data = reactive<PageData<inspectionPointsForm, inspectionPointsQuery>>({
  form: { ...initFormData },
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    spotNumber: '',
    spotName: '',
    spotStatus: '',
    routeName: ''
  },
  rules: {
    id: [{ required: true, message: '不能为空', trigger: 'blur' }],
    spotNumber: [{ required: true, message: '点编号不能为空' }],
    spotName: [{ required: true, message: '点名称不能为空' }],
    gender: [{ required: true, message: '性别不能为空', trigger: 'change' }],
    classId: [{ required: true, message: '班级id不能为空', trigger: 'blur' }],
    gradeLevel: [{ required: true, message: '级别不能为空', trigger: 'change' }],
    studentStatus: [{ required: true, message: '学生状态不能为空', trigger: 'change' }],
    recognizeTime: [{ required: true, message: '识别时间不能为空', trigger: 'blur' }],
    deviceType: [{ required: true, message: '设备类型不能为空', trigger: 'change' }],
    deviceCode: [{ required: true, message: '设备编码不能为空', trigger: 'blur' }],
    deviceName: [{ required: true, message: '设备名称不能为空', trigger: 'blur' }],
    facePic: [{ required: true, message: '图片路径不能为空', trigger: 'blur' }],
    snapshotPic: [{ required: true, message: '抓拍图不能为空', trigger: 'blur' }],
    comparisonScore: [{ required: true, message: '比对分值不能为空', trigger: 'blur' }]
  }
});

const { queryParams, form, rules } = toRefs(data);


/** 查询点设置记录列表 */
const getList = async () => {
  loading.value = true;
  const routeName = routeOptions.value.find((item) => item.routeId == queryParams.value.routeName)?.routeName;
  const obj = JSON.parse(JSON.stringify({ ...queryParams.value, routeName }));
  const res = await inspectspotlist(obj);
  portsSettingList.value = res.rows;
  total.value = res.total;
  loading.value = false;
};

/** 查询部门下拉树结构 */
const getGroupTree = async () => {
  const res = await searchinspectItemsCatalogue();
  groupOptions.value = res.data;
};

/** 获取巡检路线下值 */
const getRouteOption = async () => {
  const res  = await ApiGetInspectionRouteList({pageNum: 1, pageSize: 999});
  routeOptions.value = res.rows;
}
/** 取消按钮 */
const cancel = () => {
  reset();
  dialog.visible = false;
};

/** 表单重置 */
const reset = () => {
  form.value = { ...initFormData };
  studentRecognitionRecordFormRef.value?.resetFields();
};

/** 搜索按钮操作 */
const handleQuery = () => {
  queryParams.value.pageNum = 1;
  getList();
};

/** 重置按钮操作 */
const resetQuery = () => {
  queryFormRef.value?.resetFields();
  queryParams.value.spotNumber=""
  queryParams.value.spotStatus=""
  queryParams.value.spotName=""
  queryParams.value.routeName=""
  handleQuery();
};

/** 多选框选中数据 */
const handleSelectionChange = (selection: inspectionPointsForm[]) => {
  ids.value = selection.map((item) => item.spotId);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
};

/** 新增按钮操作 */
const handleAdd = () => {
  reset();
  selectData.value = [];
  dialog.visible = true;
  dialog.title = '新增巡检点';
};

/** 修改按钮操作 */
const handleUpdate = async (row?: inspectionPointsForm) => {
  reset();
  const _id = row?.spotId || ids.value[0];
  const res = await ApiGetInspectionSpotDetail(_id);
  form.value.routeIds = res.data?.spotRouteVos.map((item: { routeId: number; isort: number }) => item.routeId) || [];
  Object.assign(form.value, res.data);
  selectData.value = res.data?.spotItems?  res.data?.spotItems.map((item: any) => {
    item.checked = false;
    return item;
  }) : [];

  dialog.visible = true;
  dialog.title = '修改巡检点';
};

/** 提交按钮 */
const submitForm = () => {
  studentRecognitionRecordFormRef.value?.validate(async (valid: boolean) => {
    console.log('22222', form.value);
    const items =  JSON.parse(JSON.stringify(selectData.value)).map((item: { itemsName: string; itemsId: string; chance: string }, index: number) => {
      return {
        itemsName: item.itemsName,
        itemsId: item.itemsId,
        chance: item.chance || 0,
        isort: index
      };
    });
    form.value.items = items;
    if (valid) {
      buttonLoading.value = true;
      const routeIds = (form.value.routeIds as number[]).map((item, index) => { return {
            routeId: item,
            isort: index
          }} )
      const routeName = (form.value.routeIds as number[]).map((item) => routeOptions.value.find(elem => elem.routeId === item)?.routeName
          ).join(',');
      if (form.value.spotId) {
        const params = {
          spotId: form.value.spotId, //ID
          routeIds: routeIds, //路线ID
          catalogueId: form.value.catalogueId, //分类目录ID
          spotNumber: form.value.spotNumber, //点编号
          spotName: form.value.spotName, //点名称
          spotAddress: form.value.spotAddress, //点地址
          enableStatus: form.value.enableStatus, //是否启用（0正常启用 1暂停使用）
          spotStatus: form.value.spotStatus, //点状态（0正常 1异常 2处理中）
          taskStatus: form.value.taskStatus, //任务状态（0无 1正在处理 2已完成 3已取消 4超时任务）
          pictureStatus: form.value.pictureStatus, //扫一扫拍照（0保存 1不保存）
          pictureLess: form.value.pictureLess, //最少拍照（张）
          pictureMany: form.value.pictureMany, //最多拍照（张）
          inspectExplain: form.value.inspectExplain, //巡检说明
          items: items, //巡检点子项
          routeName: routeName
        };
        await ApiUpdateInspectionSpot(params).finally(() => (buttonLoading.value = false));
      } else {
        const obj = JSON.parse(JSON.stringify(form.value));
        obj.routeIds = routeIds
        obj.routeName = routeName
        await ApiCreateInspectionSpot(obj).finally(() => (buttonLoading.value = false));
      }
      proxy?.$modal.msgSuccess('修改成功');
      dialog.visible = false;
      await getList();
    }
  });
};

/** 删除按钮操作 */
const handleDelete = async (row?: inspectionPointsForm) => {
  if(!row){
    await proxy?.$modal.confirm('是否确认删除选中的"' + ids.value.length + '条数据项？').finally(() => (loading.value = false));
    await ApiDeleteInspectionSpot(ids.value);
    proxy?.$modal.msgSuccess('删除成功');
  }else{
    const _ids = row?.spotId;
  await proxy?.$modal.confirm('是否确认删除点名称为"' + row?.spotName + '"的数据项？').finally(() => (loading.value = false));
  await ApiDeleteInspectionSpot(_ids);
  proxy?.$modal.msgSuccess('删除成功');
  }
  await getList();
};

/**
 * 点击打印按钮时触发的事件
 *
 * @returns 无返回值
 */
const onClickPrint = () => {
  printJS('data:image/png;base64,' + form.value.qrCode, 'image');
}
const onClickDowload = () => {
  const url = 'data:image/png;base64,' + form.value.qrCode
  const name = (form.value as any).spotName  +form.value.spotAddress;
  downloadImage(url, name)
}
/** 导出按钮操作 */
const handleExport = () => {
  proxy?.download(
    'inspection/spot/export',
    {
      ...queryParams.value
    },
    `portsSetting_${new Date().getTime()}.xlsx`
  );
};

const downloadImage = (imageUrl: string, name: string) =>{
  const image = new Image();
  // 解决跨域 Canvas 污染问题
  image.setAttribute('crossOrigin', 'anonymous');
  image.onload = function () {
    const canvas = document.createElement('canvas');
    canvas.width = image.width;
    canvas.height = image.height;
    const context: any = canvas.getContext('2d');
    context.drawImage(image, 0, 0, image.width, image.height);
    // 得到图片的base64编码数据
    const url = canvas.toDataURL('image/png');

    // 生成一个a元素
    const a = document.createElement('a');
    // 创建一个单击事件
    const event = new MouseEvent('click');
    a.download = name;
    // 将生成的URL设置为a.href属性
    a.href = url;
    // 触发a的单击事件
    a.dispatchEvent(event);
  };
  image.src = imageUrl;
}

const onChangeCheckBoxAll = (val: any) => {
  console.log(val, 'val')
  if (val) {
    selectData.value = selectData.value.map((item: any) => {
      item.checked = true;
      return item;
    })
  } else {
    selectData.value = selectData.value.map((item: any) => {
      item.checked = false;
      return item;
    })
  }
}

const closeAddCheckDialog = () => {
  addCheckVisiable.value = false;
};

const getSelectData = (data: any) => {
  selectData.value = [...selectData.value, ...data];
  console.log(selectData.value, 'tableData');
  addCheckVisiable.value = false;
};

const onClickAdd = () => {
  addCheckVisiable.value = true;
};

const onClickDelete = () => {
  console.log(selectData.value, 'selectData');
  if (!selectData.value.some((item: any) => item.checked === true)) {
    return ElMessage.error('请选择要删除的项');
  }
  // 判断selectData中是否有checked的 或者 checked为true
  selectData.value = JSON.parse(JSON.stringify(selectData.value.filter((item: any, index: number) => !(item.checked || false))));
  console.log('删除后：', selectData.value);
};

//拖拽结束事件
const draggerEnd = (v: any) => {
  //
}

onMounted(() => {
  getRouteOption();
  getGroupTree();
  getList();
});
</script>
<style lang="scss" scoped>

@import '@/assets/styles/variables.module';
$--border-color-lighter: #edf0f5;
$--background-color-base: #f6f6f6;
$--color-text-regular: #646666;
.row-grid {
  position: relative;
  width: 100%;
  font-size: 14px;
  overflow: hidden;
  margin-top: 20px;
  margin-bottom: 10px;
  border: 1px solid $--border-color-lighter;
  border-radius: 10px;
  background-color: #fff;

  &-header {
    background-color: $--background-color-base;
  }

  &-tr {
    display: flex;
    align-items: center;
    width: 100%;

    & + .row-grid-tr {
      border-top: 1px solid $--border-color-lighter;
    }

    &--chosen {
      cursor: move;
    }

    &--ghost {
      opacity: .5;
      background-color: #f6f8fa;
    }
  }

  &-th, &-td {
    padding: 10px 16px;
    flex: auto;
    color: $--color-text-regular;
    line-height: 1.5
  }

  &-footer {
    border-top: 1px solid $--border-color-lighter;
  }

  &-empty {
    padding: 16px;
    text-align: center;
    color: $--color-text-regular;
  }

  &-right {
    text-align: right;
  }

  &-center {
    text-align: center;
  }

  &--bordered {
    .row-grid-th,
    .row-grid-td {
      & + .row-grid-th,
      & + .row-grid-td {
        border-left: 1px solid $--border-color-lighter;
      }
    }
  }
}

.attrs-table {
  width: 740px;
  line-height: 20px;
  border: 1px solid #edf0f5;

  .row-grid--draggable {
    :deep(.el-form-item__content) {
      justify-content: space-around;
    }
    .row-grid-tr {
      .serial {
        cursor: grab;
      }

      &--chosen {
        .serial {
          cursor: move;
        }
      }

      &--ghost {
        opacity: 0.1;
      }

      &--drag {
        border-bottom: 1px solid #edf0f5;
        background-color: #fff;
      }
    }
  }

  .row-grid-td {
    width: 160px;
    white-space: nowrap;

    &.serial {
      width: 40px;
      text-align: left;
      .sort {
        position: relative;
        color: #969999;
        vertical-align: middle;
        margin: 0 4px 0 -4px;
      }
    }

    &.name1 {
      width: 100px;
      text-align: center;
    }

    &.namemax {
      width: 300px;
      text-align: center;
    }

    &.action {
      width: 70px;
    }

    & + .row-grid-td {
      padding-left: 0;
    }
  }
}
</style>
